<%--
  Created by IntelliJ IDEA.
  User: Dzb
  Date: 2018/4/24
  Time: 13:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="javax.imageio.*,java.io.*"%>
<%@ page import="com.dzb.util.VerifyCode"%>
<html>
<head>
    <title>生成验证码</title>
</head>
<body>
   <%    //设置页面不缓存
      response.setHeader("Pragma","NO-cache");
      response.setHeader("Cache-Control","no-cache");
      response.setDateHeader("Expires",0);
      response.reset();
      try{
          //将认证码存入session
          //调用runVerifyCode(int i)
          VerifyCode Vc=new VerifyCode();
          String sVerifyCode=Vc.runVerifyCode(4);
          session.setAttribute("VerifyCode",sVerifyCode);
          OutputStream outs=response.getOutputStream();
          ImageIO.write(Vc.CreateImage(sVerifyCode),"JPEG",outs);
          out.clear();
          out=pageContext.pushBody();
      }catch (Exception e){
          return;
      }
   %>

</body>
</html>
